class SceneLooseEnd extends GuaScene {
    constructor(game) {
        super(game)
        this.setup()
    }

    setup() {
        this.context = this.game.context
        this.currentLevel = []
        this.setupBG()
        this.setupInputs()

    }

    draw() {
        super.draw()
        this.game.drawText('重新开始', 470, 300)
    }

// setup 系列
    setupBG() {
        let bg = PlantIcon.new(this.game, 'GameLoose')
        this.bg = bg
        this.addElement(bg)
    }


    setupInputs() {
        let self = this
        this.game.registerMouse(function (event, status) {
            let x = event.offsetX
            let y = event.offsetY

            if (status === 'down') {
                if (x > 460 && x < 590 && y > 270 && y < 310) {
                    self.updateScene()
                }

            }
        })
    }

    updateScene() {
        sleep(500).then(() => {
            let s = SceneTitle.new(this.game)
            this.game.replaceScene(s)
        })
        this.game.removeMouse()

    }
}


